#define SQUID_STANCE_IDLE 1
#define SQUID_STANCE_ATTACK 2
#define SQUID_STANCE_ATTACKING 3

/mob/living/simple_animal/deathsquid
	name = "deathsquid"
	desc = "Looks like an evil squid. You are fucked."
	icon_state = "deathsquid"
	icon_living = "deathsquid"
	icon_dead = "deathsquid_dead"
	icon_gib = "bear_gib"
	speak = list("HSSSS!")
	speak_emote = list("hisses", "squeels")
	emote_hear = list("roars","groans","hisses")
	emote_see = list("stares ferociously", "flails widly")
	speak_chance = 1
	turns_per_move = 5
	see_in_dark = 6
	meat_type = /obj/item/weapon/reagent_containers/food/snacks/meat
	response_help  = "pets the"
	response_disarm = "gently pushes the"
	response_harm   = "pokes the"

	stop_automated_movement_when_pulled = 0
	maxHealth = 250
	health = 250

	harm_intent_damage = 20
	melee_damage_lower = 15
	melee_damage_upper = 25
	attacktext = "whacks"
	attack_sound = 'bite.ogg'

	//Deathsquids aren't affected by atmos.
	min_oxy = 0
	max_oxy = 0
	min_tox = 0
	max_tox = 0
	min_co2 = 0
	max_co2 = 0
	min_n2 = 0
	max_n2 = 0
	minbodytemp = 0		//so they don't freeze in space
	maxbodytemp = 350	//if it's just 25 degrees, they start to burn up

	var/stance = SQUID_STANCE_IDLE	//Used to determine behavior
	var/stance_step = 0				//Used to delay checks depending on what stance the bear is in
	var/mob/living/target_mob		//Once the squid enters attack stance, it will try to chase this mob. This it to prevent it changing it's mind between multiple mobs.
	heat_damage_per_tick = 1

/mob/living/simple_animal/deathsquid/purple
	icon_state = "deathsquid2"
	icon_living = "deathsquid2"
	icon_dead = "deathsquid2_dead"
	icon_gib = "bear_gib"
	desc = "Looks like an evil squid. You are fucked. This one is purple!"
	maxHealth = 250
	health = 250
	melee_damage_lower = 15
	melee_damage_upper = 25

/proc/isdeathsquid(var/mob/M)
	return istype(M, /mob/living/simple_animal/deathsquid)

/mob/living/simple_animal/deathsquid/Life()
	..()

	if(!stat)
		switch(stance)
			if(SQUID_STANCE_IDLE)
				stop_automated_movement = 0
				stance_step++
				if(stance_step > 5)
					stance_step = 0
					for( var/mob/living/L in viewers(7,src) )
						if(isdeathsquid(L)) continue
						if(!L.stat)
							if(prob(50))
								src.visible_message("<b>[src]</b> roars at [L]!")
							stance = SQUID_STANCE_ATTACK
							target_mob = L
							break

			if(SQUID_STANCE_ATTACK)	//This one should only be active for one tick
				stop_automated_movement = 1
				if(!target_mob || target_mob.stat)
					stance = SQUID_STANCE_IDLE
					stance_step = 5 //Make it very alert, so it quickly attacks again if a mob returns
				if(target_mob in viewers(7,src))
					walk_to(src, target_mob, 1, 3)
					stance = SQUID_STANCE_ATTACKING
					stance_step = 0

			if(SQUID_STANCE_ATTACKING)
				stop_automated_movement = 1
				stance_step++
				if(!target_mob || target_mob.stat)
					stance = SQUID_STANCE_IDLE
					stance_step = 4 //Make it very alert, so it quickly attacks again if a mob returns
					target_mob = null
					walk(src,0)
					return
				if(!(target_mob in viewers(7,src)))
					stance = SQUID_STANCE_IDLE
					stance_step = 1
					target_mob = null
					walk(src,0)
					return
				if(get_dist(src, target_mob) <= 1)	//Attacking
					if(isliving(target_mob))
						var/mob/living/L = target_mob
						L.attack_animal(src)
						if(prob(10))
							L.Weaken(5)
							L.visible_message("<span class='danger'>\the [src] knocks down \the [L]!</span>")

/mob/living/simple_animal/deathsquid/Die()
	..()
	target_mob = null
	stance = SQUID_STANCE_IDLE
	walk(src,0)

/mob/living/simple_animal/deathsquid/Process_Spacemove(var/check_drift = 0)
	return 0	//No drifting in space for deathsquids!

/mob/living/simple_animal/deathsquid/Process_Spaceslipping(var/prob_slip = 5)
	return 0

//----